import store from '@/store'

interface ApplicationState {
    name: string
    code: string
    groups: OptionGroup[]
}

export const useApplicationStore = defineStore('application', {
    state: (): ApplicationState => {
        return {
            name: '',
            code: '',
            groups: []
        }
    },
    getters: {
        getName: (state) => state.name,
        getCode: (state) => state.code,
        getGroups: (state) => state.groups
    },
    actions: {
        setName(value: string) {
            this.name = value
        },
        setCode(value: string) {
            this.code = value
        },
        setGroups(options: OptionGroup[]) {
            this.groups = options
        }
    },
    persist: true
})


export const useApplicationStoreWithOut = () => {
    return useApplicationStore(store)
}